package com.gxa.service.asset.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.entity.asset.CheckRecords;
import com.gxa.entity.asset.search.CheckApplyAndRecordSearchMap;
import com.gxa.mapper.asset.CheckRecordsMapper;
import com.gxa.service.asset.CheckRecordsService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【t_check_apply(设备检查申请表)】的数据库操作Service实现
* @createDate 2022-10-13 16:15:45
*/
@Service
public class CheckRecordsServiceImpl extends ServiceImpl<CheckRecordsMapper, CheckRecords>
    implements CheckRecordsService {
    @Autowired
    private CheckRecordsMapper mapper;

    @Override
    public PageInfo<CheckRecords> queryByPage(CheckApplyAndRecordSearchMap map) {
        PageHelper.startPage(map.getPageNum(),map.getPageSize());//1.开启分页

        QueryWrapper<CheckRecords> wrapper = new QueryWrapper<>();//2.条件构造器 模拟写动态sql  或者在xml 中写
        if (!StringUtils.isBlank(map.getApplyId())) {
            wrapper.like("order_id", map.getApplyId());
        }
        if(!StringUtils.isBlank(map.getApplyPerson())){
            wrapper.like("apply_person_name",map.getApplyPerson());
        }
        if(!StringUtils.isBlank(map.getStatus())){
            wrapper.eq("check_status",map.getStatus());
        }
        if(!StringUtils.isAnyBlank(map.getStartTime(),map.getEndTime())){
            wrapper.between("real_check_time",map.getStartTime(),map.getEndTime());
        }
        PageInfo<CheckRecords> pageInfo = new PageInfo<>(mapper.selectList(wrapper));//3.获取分页信息
        return pageInfo;
    }
}




